<?php
namespace common\services\SMS;

use linslin\yii2\curl\Curl;
use Yii;
/**
 * 空间畅想 短信接口
 */
class SmsJiuqiu
{
    /**私有静态参数**/
    private $secretKey = '';          //账号

    private $api;
    private $listApi;

    public function __construct() {
        $this->secretKey = Yii::$app->params['SMS_JIUQIU_SECRET'];
    }

    public function send($to = '', $content = '') {
        $params['secret_key'] = $this->secretKey;
        $params['to'] = $to;
        $params['content'] = $content;

        $curl = new Curl();
        $curl->setPostParams($params);

        $res = $curl->post($this->api);
    
        $res = json_decode($res, true);

        return $res;
    }
    
    public function getList($page = 1, $size = 30, $phone = '') {
        $params["page"] = $page;
        $params["size"] = $size;
        $params['phone'] = $phone;
        
        $curl = new Curl();
        
        $curl->setGetParams($params);
        
        $res = $curl->get($this->listApi);
        
        $res = json_decode($res, true);
        
        return $res;
    }
}